<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <body>
        <ui:composition template="./../../WEB-INF/templates/noFooterTemplate.xhtml">
            <ui:define name="content">
                <h:outputStylesheet library="css" name="jquery.Jcrop.min.css"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="admin/edit_company.css"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="admin/edit_company_desktop.css" media="screen and (min-width:1025px) and (max-width:1600px)"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="admin/edit_company_desktop_wide.css" media="screen and (min-width : 1601px)"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="admin/edit_company_tablet.css" media="screen and (min-device-width : 768px) and (max-device-width : 1024px), screen and (max-width:1024px)"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="admin/edit_company_smartphone.css" media="screen and (min-device-width : 320px) and (max-device-width : 767px), screen and (max-width:767px)"></h:outputStylesheet>
                <h:outputScript library="javascript" target="head" name="modernizr.js"></h:outputScript>
                <h:outputScript library="javascript" target="body" name="masonry.js"></h:outputScript>
                <h:outputScript library="javascript" target="body" name="newEditCompany.js"></h:outputScript>
                <h:outputScript library="javascript" target="body" name="jquery.Jcrop.min.js"></h:outputScript>

                <p:toolbarGroup align="left">  
                    <p:commandButton id="viewAllButton" value="#{messages.ViewAllCompanies}" action="AdminCompanyView?faces-redirect=true"/>
                </p:toolbarGroup>
                
                <h:form id="editCompanyForm" >
                    <p:growl id="editGrowl" showDetail="false" life="4000"/> 
                </h:form>

                <h:form id="editGeneralInformationForm" styleClass="inlineBlock verticalAlignTop panelContainerWidth">
                    <p:panel id="editCompanyPanel" header="#{companyMessages.GeneralInformation}"  styleClass="noPaddingTitle noMargin noPadding panelCompany darkGrayBackgroundTitle darkGrayBorder">  
                        <p:panel styleClass="noMargin noPadding noBorder">
                            <p:inputText id="companyCredits" styleClass="editCompanyInput" required="true" value="#{adminEditCompanyBean.company.availableCredits}"  requiredMessage="#{messages.CompanyCreditsRequired}" label="#{messages.CompanyCredits}">  
                            </p:inputText>
                            <p:watermark for="companyCredits" value="#{messages.CompanyCredits}" /> 
                            <p:inputText id="companyName" styleClass="editCompanyInput" required="true" value="#{adminEditCompanyBean.company.name}"  requiredMessage="#{messages.CompanyNameRequired}" label="#{messages.CompanyName}">  
                            </p:inputText>
                            <p:watermark for="companyName" value="#{messages.CompanyName}" /> 
                            <p:inputText id="companyBusinessName" styleClass="editCompanyInput" required="false" value="#{adminEditCompanyBean.company.businessName}"  requiredMessage="#{messages.CompanyNameRequired}" label="#{messages.CompanyName}">
                            </p:inputText>
                            <p:watermark for="companyBusinessName" value="#{messages.CompanyBusinessName}" />
                            <p:inputText id="companyPhone" styleClass="editCompanyInput" required="false" value="#{adminEditCompanyBean.company.phone}"  requiredMessage="#{messages.CompanyNameRequired}" label="#{messages.CompanyName}">
                            </p:inputText>
                            <p:watermark for="companyPhone" value="#{messages.Phone}" /> 
                            <p:inputText id="companyCIF" styleClass="editCompanyInput" required="false" value="#{adminEditCompanyBean.company.cif}"  requiredMessage="#{messages.CompanyCIFRequired}" label="#{messages.CompanyCIF}">
                            </p:inputText>
                            <p:watermark for="companyCIF" value="#{messages.CompanyCif}" />
                            <p:inputText id="companyContact" styleClass="editCompanyInput" required="false" value="#{adminEditCompanyBean.company.contact}"  requiredMessage="#{messages.CompanyNameRequired}" label="#{messages.CompanyName}">
                            </p:inputText>
                            <p:watermark for="companyContact" value="#{messages.CompanyContact}" />
                            <p:selectOneMenu styleClass="editCompanyInput" filter="true" filterMatchMode="contains" required="true" converter="#{countryConverter}" id="selectCountry"  value="#{adminEditCompanyBean.company.country}" effect="fade"  label="#{messages.Country}" requiredMessage="#{messages.CountryRequired}">  
                                <f:selectItem itemLabel="#{messages.Country}" itemValue="" />  
                                <f:selectItem itemLabel="#{countryBundle[resourcesBean.spain.idCountry.toString()]}"  itemValue="#{resourcesBean.spain}" />  
                                <f:selectItems value="#{userResourcesBean.countries}" var="country" itemLabel="#{countryBundle[country.idCountry.toString()]}" itemValue="#{country}"/>  
                                <p:ajax event="change" process="@this" update="selectProvince selectTown" />
                            </p:selectOneMenu> 
                            <p:selectOneMenu styleClass="editCompanyInput" filter="true" filterMatchMode="contains" required="true" converter="#{provinceConverter}" id="selectProvince"  value="#{adminEditCompanyBean.company.province}" effect="fade"  label="#{messages.Province}" requiredMessage="#{messages.ProvinceRequired}">  
                                <f:selectItem itemLabel="#{messages.Province}" itemValue="" />  
                                <f:selectItems rendered="#{adminEditCompanyBean.company.country!=null}" value="#{userResourcesBean.countries[userResourcesBean.countries.indexOf(adminEditCompanyBean.company.country)].provinceList}" var="province" itemLabel="#{province.description}" itemValue="#{province}"/>  
                                <p:ajax event="change" process="@this" update="selectTown selectProvince" />
                            </p:selectOneMenu>
                            <p:selectOneMenu styleClass="editCompanyInput" filter="true" filterMatchMode="contains" required="true" converter="#{townConverter}" id="selectTown"  value="#{adminEditCompanyBean.company.town}" effect="fade"  label="#{messages.Town}" requiredMessage="#{messages.TownRequired}">  
                                <f:selectItem itemLabel="#{messages.Town}" itemValue="" />  
                                <f:selectItems rendered="#{adminEditCompanyBean.company.province!=null}" value="#{userResourcesBean.countries[userResourcesBean.countries.indexOf(adminEditCompanyBean.company.country)].provinceList[userResourcesBean.countries[userResourcesBean.countries.indexOf(adminEditCompanyBean.company.country)].provinceList.indexOf(adminEditCompanyBean.company.province)].townList}" var="town" itemLabel="#{town.description}" itemValue="#{town}"/>  
                                <p:ajax event="change" process="@this" update=":editCompanyForm:editGrowl selectTown" />
                            </p:selectOneMenu>
                            <p:inputText id="companyAddress" styleClass="editCompanyInput" required="false" value="#{adminEditCompanyBean.company.address}"  requiredMessage="#{messages.CompanyNameRequired}" label="#{messages.CompanyName}">
                            </p:inputText>
                            <p:watermark for="companyAddress" value="#{messages.Address}" />
                            <p:inputText id="companyPostalCode" styleClass="editCompanyInput" required="false" value="#{adminEditCompanyBean.company.postalCode}"  requiredMessage="#{messages.CompanyNameRequired}" label="#{messages.CompanyName}">
                            </p:inputText>
                            <p:watermark for="companyPostalCode" value="#{messages.PostalCode}" />
                            <p:inputTextarea autoResize="false" styleClass="ui-inputtext generalInformationTextArea inputField block width100" counterTemplate="{0} #{messages.CharactersRemaining}" id="companySummary" value="#{adminEditCompanyBean.company.summary}" maxlength="1024" counter="counter"></p:inputTextarea>
                            <p:watermark value="#{messages.CompanySummary}" for="companySummary"></p:watermark>            
                            <h:outputText styleClass="bodyText" id="counter" />

                            <p:commandButton styleClass="blueBackgroundStrong marginBottom05em editCompanyButton" value="#{messages.Update}" process="editCompanyPanel" update=":editCompanyForm:editGrowl editCompanyPanel" actionListener="#{adminEditCompanyBean.editCompany}" />                        
                        </p:panel>
                    </p:panel>
                </h:form>

                <div id="sectorsMainForm" class="inlineBlock verticalAlignTop panelContainerWidth">
                    <p:panel id="sectorsPanel" header="#{companyMessages.Sectors}"  styleClass="noPaddingTitle noMargin noPadding panelCompany darkGrayBackgroundTitle darkGrayBorder">  
                        <p:panel styleClass="noMargin noPadding noBorder">
                            <h:form id="sectorsForm" styleClass="block">
                                <p:panel styleClass="noMargin noBorder noPaddingTitle noPadding"  id="companyCurrentSector">

                                    <p:dataList styleClass=" marginTop05em dataListSectorsColumn"  var="tag" value="#{adminEditCompanyBean.company.companySectorList}"  emptyMessage="#{messages.NoSectorYet}" >
                                        <p:panel styleClass="sectorBackgroundDataListElement" style="padding:0.2em!important;"  >
                                            <div class="inlineBlock verticalAlignTop">
                                                <h:outputText  value="#{sectorBundle[tag.idSector.idSector.toString()]}" />   
                                            </div>
                                            <div class="inlineBlock verticalAlignTop">
                                                <p:commandButton style="width:20px;height: 20px" actionListener="#{adminEditCompanyBean.removeCompanySector(tag)}" styleClass="deleteButton" process="@parent" update=":editCompanyForm:editGrowl :sectorsForm:companyCurrentSector :sectorsFormAdd:addSectorPanel"  icon="ui-icon-close">
                                                </p:commandButton>
                                            </div>
                                        </p:panel>
                                    </p:dataList>
                                </p:panel>
                            </h:form>
                            <h:form id="sectorsFormAdd" styleClass="block">
                                <p:panel id="addSectorPanel" styleClass="noMargin noBorder noPaddingTitle noPadding" >

                                    <p:selectOneMenu styleClass="companySectorInput" required="true" filter="true" filterMatchMode="contains" id="editSelectSector" converter="#{sectorConverter}" value="#{adminEditCompanyBean.selectedSector}" effect="fade" label="#{messages.CompanySectors}" requiredMessage="#{messages.SectorRequired}">  
                                        <f:selectItem itemLabel="#{messages.CompanySectors}" itemValue="" />  
                                        <f:selectItems value="#{userResourcesBean.sectors}" var="sector" itemLabel="#{sectorBundle[sector.idSector.toString()]}" itemValue="#{sector}"/>  
                                    </p:selectOneMenu>

                                    <p:commandButton styleClass="blueBackgroundStrong marginBottom05em editCompanyButton" value="#{messages.Add}" process="@parent" update=":editCompanyForm:editGrowl :sectorsForm:companyCurrentSector :sectorsFormAdd:addSectorPanel" actionListener="#{adminEditCompanyBean.addCompanySector}" />
                                </p:panel>
                            </h:form>
                        </p:panel>
                    </p:panel>
                </div>

                <h:form id="editLogoForm" styleClass="inlineBlock verticalAlignTop panelContainerWidth">
                    <p:panel id="editLogoPanel" header="#{companyMessages.CompanyLogo}"  styleClass="noPaddingTitle noMargin noPadding panelCompany darkGrayBackgroundTitle darkGrayBorder">  
                        <p:panel styleClass="noMargin noPadding noBorder">
                            <div style="text-align: center;">
                                <p:commandLink onclick="$('input[type=file][class=logoFileUpload]').click()" rendered="#{adminEditCompanyBean.company.logo==null}">
                                    <h:graphicImage rendered="#{adminEditCompanyBean.company.logo==null}" style="width: 60%!important;" styleClass="marginBottom20" library="images" name="silueta1.png"></h:graphicImage>
                                </p:commandLink>
                                <p:commandLink onclick="$('input[type=file][class=logoFileUpload]').click()" rendered="#{adminEditCompanyBean.company.logo!=null}">
                                    <h:graphicImage rendered="#{adminEditCompanyBean.company.logo!=null}" style="width: 60%!important;" styleClass="marginBottom20" value="/companyFiles/#{adminEditCompanyBean.company.idCompany.toString()}/images/#{adminEditCompanyBean.company.logo}"></h:graphicImage>
                                </p:commandLink>
                            </div>
                            <p:fileUpload auto="true" styleClass="logoFileUpload" id="imageFileUploader" uploadLabel="#{messages.Upload}" label="#{messages.BustImageFileUploadLabel}" cancelLabel="#{messages.Cancel}" invalidSizeMessage="#{messages.BustFileSize}" invalidFileMessage="#{messages.BustFileFormat}" requiredMessage="#{messages.BustRequired}" fileUploadListener="#{adminEditCompanyBean.uploadLogo}" update="editLogoPanel" process="@parent" sizeLimit="3000000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />

                            <p:commandButton  styleClass="blueBackgroundStrong marginBottom05em editCompanyButtonInLine" value="#{messages.Update}" process="editLogoPanel" update=":editCompanyForm:editGrowl editLogoPanel" actionListener="#{adminEditCompanyBean.editCompany}" rendered="#{adminEditCompanyBean.oldLogo!=null}"/>                        
                            <p:commandButton  styleClass="blueBackgroundStrong marginBottom05em editCompanyButtonInLine" value="#{messages.Cancel}" process="editLogoPanel" update=":editCompanyForm:editGrowl editLogoPanel" actionListener="#{adminEditCompanyBean.cancelUploadLogo}" rendered="#{adminEditCompanyBean.oldLogo!=null}"/>

                        </p:panel>
                    </p:panel>
                </h:form>

            </ui:define>
        </ui:composition>
    </body>
</html>
